from common.base_model import BaseModel, BasicModelMixin, CompanyMixin, CreateMixin
from exts import db
from common import constant
from app.coin.dao import get_by_page


# 积分系统
class CoinRecord(BasicModelMixin, db.Model, CompanyMixin, CreateMixin):
    __tablename__ = 'coin_record'

    id = db.Column(db.Integer, primary_key=True)

    user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
    action_name = db.Column(db.String(constant.MIDDLE_DB_STR_LEN), default=constant.CoinUseAction.USE_COUPON)
    coins_used = db.Column(db.DECIMAL(20, constant.COMMON_DECIMAL), default=1)
    company_current_coins = db.Column(db.DECIMAL(20, constant.COMMON_DECIMAL), default=0)

    @staticmethod
    def dao_get_by_page(**kwargs):
        return get_by_page(**kwargs)


